package com.practice.nacos.config.example;

import com.alibaba.cloud.nacos.NacosConfigManager;
import com.practice.nacos.config.example.config.UserConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author yangdejun
 * @date 2020/12/01
 **/
@RestController
public class TestController {
    @Autowired
    UserConfig userConfig;

    @Value("${user.name}")
    String userName;

    @Value("${user.age}")
    Integer age;

    @Autowired
    private NacosConfigManager nacosConfigManager;

    @GetMapping(value = "/user")
    public String simple() {
        return "Hello Nacos Config!" + "Hello " + userName + " " + age + " [UserConfig]: " + userConfig
                + "!" + nacosConfigManager.getConfigService();
    }
}
